using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Attributes;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Attributes.DomainAttributes;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Enums;
using System.Collections.Generic;
using System.ComponentModel;

namespace Baci.ArcGIS._DataManagementTools._GeodatabaseAdministration
{
    /// <summary>
    /// <para>Create Database User</para>
    /// <para>Creates a database user with privileges sufficient to create data in the database.</para>
    /// <para>创建一个数据库用户，该用户具有足以在数据库中创建数据的权限。</para>
    /// </summary>    
    [DisplayName("Create Database User")]
    public class CreateDatabaseUser : AbstractGPProcess
    {
        /// <summary>
        /// 无参构造
        /// </summary>
        public CreateDatabaseUser()
        {

        }

        /// <summary>
        /// 有参构造
        /// </summary>
        /// <param name="_input_database">
        /// <para>Input Database Connection</para>
        /// <para>The connection file to an enterprise geodatabase in Oracle, PostgreSQL, or SQL Server. Be sure the connection is made as a database administrator user. When connecting to Oracle, you must connect as the sys user.</para>
        /// <para>与 Oracle、PostgreSQL 或 SQL Server 中的企业级地理数据库的连接文件。确保以数据库管理员用户身份建立连接。连接到 Oracle 时，必须以 sys 用户身份进行连接。</para>
        /// </param>
        /// <param name="_user_name">
        /// <para>Database User</para>
        /// <para><xdoc>
        ///   <para>The name of the new database user.</para>
        ///   <para>If you chose to create a database user for an operating system login, the user name must match the login name.</para>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>新数据库用户的名称。</para>
        ///   <para>如果选择为操作系统登录名创建数据库用户，则用户名必须与登录名匹配。</para>
        /// </xdoc></para>
        /// </param>
        public CreateDatabaseUser(object _input_database, object _user_name)
        {
            this._input_database = _input_database;
            this._user_name = _user_name;
        }
        public override string ToolboxName => "Data Management Tools";

        public override string ToolName => "Create Database User";

        public override string CallName => "management.CreateDatabaseUser";

        public override List<string> AcceptEnvironments => ["workspace"];

        public override object[] ParameterInfo => [_input_database, _user_authentication_type.GetGPValue(), _user_name, _user_password, _role, _tablespace_name, _out_result];

        /// <summary>
        /// <para>Input Database Connection</para>
        /// <para>The connection file to an enterprise geodatabase in Oracle, PostgreSQL, or SQL Server. Be sure the connection is made as a database administrator user. When connecting to Oracle, you must connect as the sys user.</para>
        /// <para>与 Oracle、PostgreSQL 或 SQL Server 中的企业级地理数据库的连接文件。确保以数据库管理员用户身份建立连接。连接到 Oracle 时，必须以 sys 用户身份进行连接。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Input Database Connection")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _input_database { get; set; }


        /// <summary>
        /// <para>Create Operating System Authenticated User</para>
        /// <para><xdoc>
        ///   <para>Specifies the authentication type for the user. Use this parameter only if an operating system login exists for which you want to create a database user. This option is only supported for SQL Server and Oracle databases, as those are the only two databases for which ArcGIS supports operating system authentication.</para>
        ///   <bulletList>
        ///     <bullet_item>Checked—An operating system-authenticated user is created. The corresponding login must already exist.</bullet_item><para/>
        ///     <bullet_item>Unchecked—A database-authenticated user is created. This is the default.</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>指定用户的身份验证类型。仅当存在要为其创建数据库用户的操作系统登录名时，才使用此参数。此选项仅支持 SQL Server 和 Oracle 数据库，因为这是 ArcGIS 支持操作系统身份验证的仅有的两个数据库。</para>
        ///   <bulletList>
        ///     <bullet_item>选中 - 创建经过操作系统身份验证的用户。相应的登录名必须已存在。</bullet_item><para/>
        ///     <bullet_item>未选中 - 创建经过数据库身份验证的用户。这是默认设置。</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Create Operating System Authenticated User")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public _user_authentication_type_value _user_authentication_type { get; set; } = _user_authentication_type_value._false;

        public enum _user_authentication_type_value
        {
            /// <summary>
            /// <para>OPERATING_SYSTEM_USER</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("OPERATING_SYSTEM_USER")]
            [GPEnumValue("true")]
            _true,

            /// <summary>
            /// <para>DATABASE_USER</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("DATABASE_USER")]
            [GPEnumValue("false")]
            _false,

        }

        /// <summary>
        /// <para>Database User</para>
        /// <para><xdoc>
        ///   <para>The name of the new database user.</para>
        ///   <para>If you chose to create a database user for an operating system login, the user name must match the login name.</para>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>新数据库用户的名称。</para>
        ///   <para>如果选择为操作系统登录名创建数据库用户，则用户名必须与登录名匹配。</para>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Database User")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _user_name { get; set; }


        /// <summary>
        /// <para>Database User Password</para>
        /// <para><xdoc>
        ///   <para>The password for the new user. The password policy of the underlying database is enforced.</para>
        ///   <para>If you chose to create a database user for an operating system login, no input is required.</para>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>新用户的密码。将强制执行基础数据库的密码策略。</para>
        ///   <para>如果选择为操作系统登录创建数据库用户，则不需要输入。</para>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Database User Password")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public object _user_password { get; set; } = null;


        /// <summary>
        /// <para>Role</para>
        /// <para>To add the new user to an existing database role, specify the name of the role.</para>
        /// <para>若要将新用户添加到现有数据库角色，请指定该角色的名称。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Role")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public object _role { get; set; } = null;


        /// <summary>
        /// <para>Tablespace Name</para>
        /// <para>When creating a user in an Oracle database, type the name of the tablespace to be used as the default tablespace for the user. You can specify a preconfigured tablespace, or, if the tablespace does not yet exist, it will be created in the Oracle default storage location with its size set to 400 MB. If no tablespace is specified, the user's default tablespace will be set to the Oracle default tablespace.</para>
        /// <para>在 Oracle 数据库中创建用户时，请键入要用作用户缺省表空间的表空间的名称。您可以指定一个预配置的表空间，或者，如果该表空间尚不存在，则将在 Oracle 默认存储位置创建该表空间，其大小设置为 400 MB。如果未指定表空间，则用户的缺省表空间将设置为 Oracle 缺省表空间。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Tablespace Name")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public object _tablespace_name { get; set; } = null;


        /// <summary>
        /// <para>Database User Created</para>
        /// <para></para>
        /// <para></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Database User Created")]
        [Description("")]
        [Option(OptionTypeEnum.derived)]
        public object _out_result { get; set; }


        public CreateDatabaseUser SetEnv(object workspace = null)
        {
            base.SetEnv(workspace: workspace);
            return this;
        }

    }

}